package com.two.reggie.utils;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 客户端工具类
 * 
 * @author ruoyi
 */
public class ServletUtils {
    public static final String MEDIA_TYPE_JSON = "application/json;charset=utf-8";

    /**
     * 将字符串渲染到客户端
     * 
     * @param response 渲染对象
     * @param string 待渲染的字符串
     */
    public static void renderString(HttpServletResponse response, String string)
    {
        try
        {
            response.setStatus(200);
            response.setContentType(MEDIA_TYPE_JSON);
            response.getWriter().print(string);
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
    }
}
